#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1;
        int max = min(height[left], height[right]) * (right - left);

        while (left < right)
        {
            if (height[left] < height[right])
                left++;
            else
                right--;

            int temp = min(height[left], height[right]) * (right - left);
            max = max >= temp ? max : temp;
        }

        return max;
    }
};